import prompt from '@system.prompt';

export default {
    data: {
        title: "",
        topTabSelected: 2,
        bottomTabSelected: 0,
        playerIndex: 0,
        duration: 0,
        isPlaying: true,
        list: [{
                   videoPath: "/common/video/video1.mp4"
               }
        , {
                   videoPath: "/common/video/video2.mp4"
               }
        , {
                   videoPath: "/common/video/video3.mp4"
               }
        , {
                   videoPath: "/common/video/video4.mp4"
               }
        , {
                   videoPath: "/common/video/video5.mp4"
               }
        ]
    },
    topTabClick(i) {
        this.topTabSelected = i;
    },
    bottomTabClick(i) {
        this.bottomTabSelected = i;
    },
    changeVideo(obj) {
        this.$element(`playerId${this.playerIndex}`).pause();
        this.playerIndex = obj.index;
        this.$element(`playerId${this.playerIndex}`).start();
    },
    preparedCallback: function (e) {
        this.event = '视频连接成功';
        this.duration = e.duration;
    },
    startCallback: function () {
        console.info('视频开始播放')
        this.event = '视频开始播放';
        this.isPlaying = true;
    },
    pauseCallback: function () {
        this.event = '视频暂停播放';
        this.isPlaying = false;
    },
    finishCallback: function () {
        this.event = '视频播放结束';
    },
    errorCallback: function () {
        this.event = '视频播放错误';
    },
    seekingCallback: function (e) {
        this.seekingtime = e.currenttime;
    },
    timeupdateCallback: function (e) {
        this.timeupdatetime = e.currenttime;
    },
    changePlayeStatus: function () {
        if (this.isPlaying) {
            this.$element(`playerId${this.playerIndex}`).pause();
            this.isPlaying = false;
        } else {
            this.$element(`playerId${this.playerIndex}`).start();
            this.isPlaying = true;
        }
    },

    share() {
        prompt.showToast(
            {
                message: '分享功能待开发'
            }
        )
    },
    collect() {
        prompt.showToast(
            {
                message: '收藏功能待开发'
            }
        )
    }
}
